package cn.zqy.demo2.day13StreamAndMethodReference.Stream;

import java.util.stream.Stream;
/*
    Stream流中的常用方法_concat:用于把流组合到一起
    如果有两个流，希望合并成为一个流，那么可以使用Stream接口的静态方法concat
    static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b)
 */
public class Demo10Concat {
    public static void main(String[] args) {
        //创建两个Stream流
        String[] strs = new String[]{"aa", "cc", "ddd", "eee", "pp"};
        Stream<String> stream1 = Stream.of("张三","张飞","王五","赵六","张明明","王老五");
        Stream<String> stream2 = Stream.of(strs);

        //把以上两个流组合为一个流
        Stream<String> concat = Stream.concat(stream1, stream2);
        concat.forEach(name -> System.out.println(name));
    }
}
